import pygame
import math as Math

class Particle:
	def __init__(self,x,y,r,a):
		self.x = x
		self.y = y
		self.r = r
		self.a = a
		self.q = 0

class Particle_Group:
	def __init__(self,x,y,n,col):
		#self.surf = pygame.Surface((100,100))
		r = 5
		self.n = n
		self.part_list = []
		self.col = col
		for i in range(0,n/4):
			part_tmp = Particle(int(r*Math.cos(Math.radians(i*5))+32),int(r*Math.sin(Math.radians(i*5))+32),r,i)
			self.part_list.append(part_tmp)
			self.q = 0
		for i in range((n/4), (n/4)*2):
			part_tmp = Particle(int(r*Math.cos(Math.radians(i*5))+32),int(-r*Math.sin(Math.radians(i*5))+32),r,i)
			self.part_list.append(part_tmp)
			self.q = 1
		for i in range((n/4)*2,(n/4)*3):
			part_tmp = Particle(int(r*Math.cos(Math.radians(i*5))+32),int(-r*Math.sin(Math.radians(i*5))+32),r,i)
			self.part_list.append(part_tmp)
			self.q = 2			
	
	def draw(self, surf):
		surf.fill((255,0,255))
		for part_tmp in self.part_list:
			surf.set_at((part_tmp.x,part_tmp.y),self.col)
		return surf
		
	
	def update(self):
		for part_tmp in self.part_list:
			part_tmp.r = part_tmp.r + 2
			if self.q == 0:
				part_tmp.x = int(part_tmp.r*Math.cos(Math.radians(part_tmp.a*5)+32))
				part_tmp.y = int(part_tmp.r*Math.sin(Math.radians(part_tmp.a*5)+32))
			if self.q == 1:
				part_tmp.x = int(part_tmp.r*Math.cos(Math.radians(part_tmp.a*5)+32))
				part_tmp.y = int(-part_tmp.r*Math.sin(Math.radians(part_tmp.a*5)+32))
			if self.q == 2:
				part_tmp.x = int(-part_tmp.r*Math.cos(Math.radians(part_tmp.a*5)+32))
				part_tmp.y = int(part_tmp.r*Math.sin(Math.radians(part_tmp.a*5)+32))
			if part_tmp.r > 100:
				self.part_list.remove(part_tmp)